package com.example.fresh_fruit.service.Impl;

import com.example.fresh_fruit.entity.Purchase;
import com.example.fresh_fruit.mapper.PurchaseMapper;
import com.example.fresh_fruit.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author :飞天の鱼
 * @date : 2022/8/18 15:03
 */
@Service
public class PurchaseServiceImpl implements PurchaseService {

    @Autowired
    private PurchaseMapper purchaseMapper;


    @Override
    public List<Purchase> selectAll() {
        return purchaseMapper.selectAll();
    }

    @Override
    public int insertPurchase(LocalDateTime startTime) {
        int insertPurchase = purchaseMapper.insertPurchase(startTime);
        if (insertPurchase==0){
            return 0;
        }
        return 1;
    }

    @Override
    public int updataState() {
        return purchaseMapper.updataState();
    }

    @Override
    public Purchase selectById(Integer id) {
        return purchaseMapper.selectById(id);
    }
}
